﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/client/2007" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:controls="clr-namespace:Utils.WP7.Bing.Controls"
    xmlns:converters="clr-namespace:Utils.WP7.Bing">

    <!-- Converters. -->
    <converters:TotalSecondsConverter x:Key="seconds" />
    <converters:KilometersConverter x:Key="kilometers" />

    <!-- Formatting for the text an ItineraryItem. -->
    <Style TargetType="controls:ItineraryItemBlock" x:Key="ItineraryItemBlock">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:ItineraryItemBlock">
                    <TextBlock x:Name="ItemTextBlock" TextWrapping="Wrap" LineStackingStrategy="BlockLineHeight" LineHeight="43" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Style for our metadata (like Index, Duration, ...) -->
    <Style TargetType="TextBlock" x:Key="ItineraryItemMetadata">
        <Setter Property="Opacity" Value="0.65" />
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}" />
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}" />
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}" />
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="VerticalAlignment" Value="Center" />
    </Style>

    <!-- Template for a full item (includes duration and time) -->
    <DataTemplate x:Key="ItineraryItemComplete">
        <Grid Height="173" Margin="12,0,12,12">
            <!-- Left part: Index, Distance, Duration. -->
            <Grid HorizontalAlignment="Left" Width="75">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="25*" />
                    <ColumnDefinition Width="25*" />
                    <ColumnDefinition Width="25*" />
                    <ColumnDefinition Width="25*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50*"></RowDefinition>
                    <RowDefinition Height="20*"></RowDefinition>
                    <RowDefinition Height="20*"></RowDefinition>
                </Grid.RowDefinitions>

                <!-- Gray rectangle. -->
                <Rectangle Grid.ColumnSpan="4" Grid.RowSpan="3" Fill="#FF0189B4" />

                <!-- Metadata fields. -->
                <TextBlock Text="{Binding Index}" Style="{StaticResource ItineraryItemMetadata}"
                           Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" />
                <TextBlock Text="{Binding Distance, Converter={StaticResource kilometers}}" Style="{StaticResource ItineraryItemMetadata}" FontSize="{StaticResource PhoneFontSizeSmall}"
                           Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" />
                <TextBlock Text="{Binding TotalSeconds, Converter={StaticResource seconds}}" Style="{StaticResource ItineraryItemMetadata}" FontSize="{StaticResource PhoneFontSizeSmall}" 
                           Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" />
            </Grid>

            <!-- Right part to show directions. -->
            <StackPanel Margin="84,-4,0,0" VerticalAlignment="Top" >
                <controls:ItineraryItemBlock Text="{Binding Text}" Style="{StaticResource ItineraryItemBlock}"
                                         FontSize="{StaticResource PhoneFontSizeLarge}" Foreground="{StaticResource PhoneForegroundBrush}"  
                                         Padding="0,3,0,0" Margin="0,0,0,5" />
            </StackPanel>
        </Grid>
    </DataTemplate>
</ResourceDictionary>
